<template>
    <div>
    <el-dropdown trigger="click" @command="handleSetLanguage" >
         <span>Language
             <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="zh">中文</el-dropdown-item>
            <el-dropdown-item command="en">English</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
    </div>
</template>

<script>
    export default {
        computed:{
            lang(){
                return localStorage.getItem("language") || 'zh'
            }
        },
        methods:{
            handleSetLanguage(lang){
                this.$i18n.locale=lang
                localStorage.setItem("language",lang)
                console.log(lang)
                // this.$store.commit('setLanguage',lang)
                this.$message({
                    message:'Switch Language Success',
                    type:'success'
                })
            }
        }
    }
</script>

<style scoped>

</style>